package com.online.studyonline.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.online.studyonline.mapper.CourseMapper;
import com.online.studyonline.pojo.Course;
import com.online.studyonline.pojo.ResultT;
import com.online.studyonline.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {
    @Autowired
    private CourseMapper courseMapper;

    @Override
    public ResultT<List<String>> getCourseName() {
        List<String> nameList = courseMapper.getCourseName();
        return ResultT.success(nameList);
    }

    @Override
    public Course getByName(String courseName) {
        QueryWrapper<Course> wrapper = new QueryWrapper<Course>()
                .eq("course_name",courseName);
        return getOne(wrapper);
    }
}
